package com.ywb;

import com.ywb.Service.TradeDataGenerator;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

import java.util.HashMap;
import java.util.Map;

@SpringBootApplication
public class DataGeneratorApp {
    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(DataGeneratorApp.class, args);
        TradeDataGenerator generator = context.getBean(TradeDataGenerator.class);

        // 配置示例：中国（country_id=1）占70%，美国（country_id=2）占30%
        Map<Integer, Double> countryWeights = new HashMap<>();
        countryWeights.put(1, 57*8.2);
        countryWeights.put(2, 57*9.2);
        countryWeights.put(3, 57*6.3);
        countryWeights.put(4, 57*4.1);
        countryWeights.put(5, 57*3.7);
        countryWeights.put(6, 57*2.9);
        countryWeights.put(7, 57*5.4);
        countryWeights.put(8, 57*4.8);
        countryWeights.put(9, 57*3.2);
        countryWeights.put(10, 57*1.9);
        countryWeights.put(11, 57*1.7);
        for (int i=12; i<=21; i++)
        {
            countryWeights.put(i, 57*0.95);
        }
        countryWeights.put(22, 18*28.1);
        countryWeights.put(23, 18*12.4);
        countryWeights.put(24, 18*9.8);
        countryWeights.put(25, 18*8.9);
        countryWeights.put(26, 18*7.6);
        countryWeights.put(27, 18*15.3);
        countryWeights.put(28, 18*5.2);
        countryWeights.put(29, 18*3.4);
        countryWeights.put(30, 18*2.8);
        for (int i=31; i<=36; i++)
        {
            countryWeights.put(i, 18*0.11);
        }
        countryWeights.put(37, 13*72.3);
        countryWeights.put(38, 13*18.5);
        countryWeights.put(39, 13*8.2);
        countryWeights.put(40, 13*0.5);
        countryWeights.put(41, 13*0.5);
        countryWeights.put(42, 4*55.2);
        countryWeights.put(43, 4*20.1);
        countryWeights.put(44, 4*15.4);
        countryWeights.put(45, 4*9.3);
        countryWeights.put(46, 3*85.1);
        countryWeights.put(47, 3*14.9);
        countryWeights.put(48, 5*48.4);
        countryWeights.put(49, 5*33.3);
        countryWeights.put(50, 5*18.3);

        // 配置示例：原油（commodity_id=100）占50%，其他商品均分剩余50%
        Map<Integer, Double> commodityWeights = new HashMap<>();
        commodityWeights.put(24,2.0);
        commodityWeights.put(68,8.0);
        commodityWeights.put(69,3.0);
        commodityWeights.put(70,2.0);
        commodityWeights.put(64,13.0);
        commodityWeights.put(61,5.0);
        commodityWeights.put(65,3.5);
        commodityWeights.put(66,6.0);
        commodityWeights.put(81,9.0);
        Map<Integer, Double> commodityGroups = new HashMap<>();
        commodityGroups.put(1, 2.19);    // 组1-10总权重0.5
        commodityGroups.put(11, 0.1);   // 组11-20总权重0.3
        commodityGroups.put(21, 9.0);
        commodityGroups.put(31, 0.2);
        commodityGroups.put(41, 0.01);
        commodityGroups.put(51, 0.12);
        commodityGroups.put(61, 7.0);
        commodityGroups.put(71, 0.02);
        commodityGroups.put(81, 1.0);
        commodityGroups.put(91, 1.36);
        commodityGroups.put(101, 2.0);
        commodityGroups.put(111, 3.3);
        commodityGroups.put(121, 0.01);
        commodityGroups.put(131, 0.01);
        commodityGroups.put(141, 0.01);
        commodityGroups.put(151, 0.01);
        commodityGroups.put(161, 0.2);
        commodityGroups.put(171, 0.1);
        commodityGroups.put(181, 1.0);
        commodityGroups.put(191, 0.01);
        commodityGroups.put(201, 0.01);
        commodityGroups.put(211, 0.2);
        commodityGroups.put(221, 0.01);
        commodityGroups.put(231, 0.1);
        commodityGroups.put(241, 8.4);
        commodityGroups.put(251, 0.3);
        commodityGroups.put(261, 0.1);
        commodityGroups.put(271, 0.02);
        commodityGroups.put(281, 2.2);
        commodityGroups.put(291, 2.87);
        commodityGroups.put(301, 0.01);
        commodityGroups.put(311, 1.0);
        commodityGroups.put(321, 1.0);
        commodityGroups.put(331, 2.0);
        commodityGroups.put(341, 0.2);
        commodityGroups.put(351, 0.01);
        commodityGroups.put(361, 1.0);
        commodityGroups.put(371, 0.9);
        commodityGroups.put(381, 0.2);
        commodityGroups.put(391, 0.3);
        commodityGroups.put(401, 0.5);
        commodityGroups.put(411, 3.2);
        commodityGroups.put(421, 2.1);
        commodityGroups.put(431, 0.01);
        commodityGroups.put(441, 0.2);

        generator.generateData(
                10000000,          // 总记录数
                countryWeights,  // 国家权重（示例为空）
                commodityWeights,
                commodityGroups,
                10               // 商品组大小
        );

    }


}